package TP2;

import TP2.sorters.BubbleSorter;
import TP2.sorters.InsertionSorter;
import TP2.sorters.SelectionSorter;
import TP3.ejercicio2.*;
import anaydis.sort.Sorter;
import anaydis.sort.SorterType;
import anaydis.sort.provider.SorterProvider;

import java.util.EnumMap;
import java.util.Map;

public class SorterProviderImpl implements SorterProvider {
    private Map<SorterType, Sorter> sorters;

    public SorterProviderImpl() {
        sorters = new EnumMap<SorterType, Sorter>(SorterType.class);
        sorters.put(SorterType.BUBBLE, new BubbleSorter());
        sorters.put(SorterType.INSERTION, new InsertionSorter());
        sorters.put(SorterType.SELECTION, new SelectionSorter());
        sorters.put(SorterType.H, new HSorter());
        sorters.put(SorterType.SHELL, new ShellSorter());
        sorters.put(SorterType.QUICK, new ShellSorter());
    }

    public Sorter getSorterForType(SorterType type){
        return sorters.get(type);
    }

    public Iterable<Sorter> getAllSorters(){
        return sorters.values();
    }
}
